/**
 * 
 */
package us.gaaoc.framework.webapp.backingbeans;

import java.io.Serializable;
import java.util.Map;

import javax.faces.context.FacesContext;
import javax.faces.validator.ValidatorException;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import us.gaaoc.framework.dao.ModelFacade;
import us.gaaoc.framework.dao.ModelFacadeHibernate;
import us.gaaoc.framework.dao.persistenceLogic.BaseDataAccessor;

/**
 * @author Sukhada
 * Jun 8, 2006
 * GAJE_BibbCounty_1.0
 */


//@Configurable
//this is configured in the XML. The reason for this is
//	that eclipse and aspectj will break
//  the class hiearchy and show errors which 
//	don't mean anything.


/*NOTE:
 * 	@Transactional should not really be on a web bean
 * but the webapp.backingbeans.* classes
 * are written to expect certain behavior that
 * Transactional provides.
 * 
 * 
 */
@Transactional(noRollbackFor=ValidatorException.class)
public class BaseBackingBean extends BaseDataAccessor implements Serializable   {

	
	private FacesContext facesContext;
	private static FacesContext staticFacesContext;
	private static boolean isStatic = false;
	
	public Map getSessionMap()
	{
		return FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
	}
	
	public HttpSession getHttpSession()
	{
		return (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true); 
	}
	
	/**
	 * @return Returns the facesContext.
	 */
	public FacesContext getFacesContext() {
		if(isStatic) return staticFacesContext;
		return FacesContext.getCurrentInstance();
	}

	/**
	 * @param facesContext The facesContext to set.
	 */
	public static void setStaticFacesContext(FacesContext facesContext) {
		staticFacesContext = facesContext;
	}

	public void setFacesContext(FacesContext facesContext) {
		
	}
	
	public static void setStatic(boolean b) {
		// TODO Auto-generated method stub
		isStatic = b;		
	}


}
